package com.sang.support;

import java.io.Serializable;

public class Result<T> implements Serializable {

    private boolean flag = true;//是否成功
    private Integer status = 200;//状态码
    private String message;//提示信息
    private T data;

    public Result(boolean flag, String message) {
        this.flag = flag;
        this.message = message;
    }

    public Result(T data){
        this.data = data;
    }

    public boolean isFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static <D> Result<D> build(D data){
        return new Result(data);
    }

    public static Result buildError(String message){
        return new Result(false,message);
    }
}
